package com.share.spring;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * author:caifan
 * date:2019/5/13
 */
@Slf4j
@Data
public class ConfigBean {

    @ApolloConfig
    Config config;
    @ApolloConfig("development.db-config")
    Config dbConfig;
    @Value("${username:root}")
    private String username;

    @PostConstruct
    public void init() {
        log.info("username:", username);
        log.info("config keys:{}", config.getPropertyNames());
        log.info("db config keys:{}", dbConfig.getPropertyNames());
    }
}
